from selenium.webdriver.support.wait import WebDriverWait

from utils import FoxDriverUtil


class ElementBase(object):

    def __init__(self):
        self.fox_driver = FoxDriverUtil.get_driver()

    def posit_element(self, location, timeout=10, step=0.5):
        return WebDriverWait(self.fox_driver, timeout, step).until(lambda x : x.find_element(*location))

    def input_element(self, element, value):
        element.send_keys(value)

    def click_element(self, element):
        element.click()

    def get_alert_info(self, location):
        return self.posit_element(location).text